<?php 
	/**
	 * 主程序，每日抓取最新数据，并提取和入库
	 */
	header("Content-Type:text/html;charset=utf-8");
	include_once dirname(dirname(__FILE__))."/include/common.inc.php";
	include_once dirname(dirname(__FILE__))."/yuanlai/function.yuanlai.php";
	$global_site = "yuanlai";
	
	//抓取日期，默认为昨天
	$ymd =  date("Y-m-d", time()-60*60*24);
	if ($argc > 1) {
		$ymd = date("Y-m-d", strtotime($argv[1]));
	}
	/*
	//是否删除数据库中已经存在的数据
	if($argc > 2 && $argv[2] == "DELETE"){
		global $conn;
		$tblName = getTblname($ymd);
		$sql = "delete from $tblName where `from`='yuanlai' and fetch_date='$ymd' ";
		$conn->query($sql);
	}
	
	$minId = getYuanlaiMinId($ymd);
	$maxId = getYuanlaiMaxId($ymd);
	$maxIdFinished = getyuanlaiMaxIdFinished($ymd);
	printlog("yesterday min uid: $minId / max uid: $maxId / finished uid: $maxIdFinished", "main");
	$minId = ($maxIdFinished > $minId) ? $maxIdFinished : $minId; 
	echo $minId."\n";
	echo $maxId."\n";
	//生成登录后的cookie
	//makeYuanlaiCookie();
	
	//抓取，提取和入库
	yuanlai_crawl($minId, $maxId, $ymd);	
	*/
	$uid = '6248841';
	$file = $uid.".html";
	$text = file_get_contents($file);
	doWithYuanlai($text);
	
	
	
	
?>